package com.bilibili.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.bilibili.entity.CommenResult;
import com.bilibili.entity.User;
import com.bilibili.service.UserService;
import com.bilibili.service.impl.UserServiceImpl;


@WebServlet("/allUserByUserId.do")
public class AllUserByUserIdServlet extends HttpServlet {
	UserService us = new UserServiceImpl();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		   	response.setContentType("application/json;charset=utf-8");
		   	String userId = request.getParameter("userId");
		   	int user_id;
		   	if(userId=="") {
				user_id=-1;
			}else {
				user_id=Integer.parseInt(userId);
			}
	        List<User> list = us.SelectUserByUserId(user_id);
	        CommenResult result = new CommenResult();
	        result.setData(list);
	        response.getWriter().write(result.toJOSNString());
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
